﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
//using Logger = Garlic.CC.Utility.Logger;
using Garlic.DAL;
using Garlic.Infrustructure;


namespace Garlic.BLL.BusinessDeal
{
    public class StSchedulesManager
    {
        StSchedulesDAL dal = new StSchedulesDAL();
        /// <summary>
        /// GetTable
        /// </summary>
        /// <param name="textWhere">conditon</param>
        /// <param name="orderText">sort</param>
        /// <returns></returns>
        public DataTable GetTable(string textWhere, string orderText)
        {
            try
            {
                return dal.GetTable(textWhere, orderText);
            }
            catch (Exception e)
            {
                Logger.Instance.Error(this, "获取数据出错" + textWhere + "|" + orderText, e);
                throw;
            }
        }

        /// <summary>
        ///  将数据写入数据。
        /// </summary>
        /// <param name="user_id"></param>
        /// <param name="cnname"></param>
        /// <param name="enname"></param>
        /// <param name="ivoyage"></param>
        /// <param name="evoyage"></param>
        /// <param name="eta"></param>
        /// <param name="etd"></param>
        /// <param name="state"></param>
        /// <param name="ter_id"></param>
        /// <param name="culoc"></param>
        /// <param name="pilotage"></param>
        /// <param name="fid"></param>
        /// <param name="nid"></param>
        /// <param name="sln_id"></param>
        /// <param name="flt_id"></param>
        /// <returns></returns>
        public string InsertToTable(string user_id, string cnname, string enname, string ivoyage, string evoyage, DateTime eta
           , DateTime etd, string state, string ter_id, string culoc, string pilotage, string fid, string nid, string sln_id, string flt_id, string vsl_code)
        {
            try
            {
                return dal.InsertToTable(user_id, cnname, enname, ivoyage, evoyage, eta
               , etd, state, ter_id, culoc, pilotage, fid, nid, sln_id, flt_id,vsl_code);
            }
            catch (Exception e)
            {
                Logger.Instance.Error(this, "写入数据出错", e);
                throw;
            }
        }

        /// <summary>
        /// 更新数据.
        /// </summary>
        /// <param name="scd_id"></param>
        /// <param name="user_id"></param>
        /// <param name="cnname"></param>
        /// <param name="enname"></param>
        /// <param name="ivoyage"></param>
        /// <param name="evoyage"></param>
        /// <param name="eta"></param>
        /// <param name="etd"></param>
        /// <param name="state"></param>
        /// <param name="ter_id"></param>
        /// <param name="culoc"></param>
        /// <param name="pilotage"></param>
        /// <param name="fid"></param>
        /// <param name="nid"></param>
        /// <param name="flt_id"></param>
        /// <returns></returns>
        public string UpdateSchedule(string scd_id, string user_id, string cnname, string enname, string ivoyage, string evoyage, DateTime eta
            , DateTime etd, string state, string ter_id, string culoc, string pilotage, string fid, string nid, string flt_id,string vsl_code)
        {
            try
            {
                return dal.UpdateSchedule(scd_id, user_id, cnname, enname, ivoyage, evoyage, eta
               , etd, state, ter_id, culoc, pilotage, fid, nid, flt_id, vsl_code);
            }
            catch (Exception e)
            {
                Logger.Instance.Error(this, "写入数据出错", e);
                throw;
            }
        }

        /// <summary>
        /// 删除船期表数据。 
        /// </summary>
        /// <param name="scd_id"></param>
        public string DeleteBySCD_ID(string scd_id)
        {
            try
            {
                dal.DeleteBySCD_ID(scd_id);
                return "1:数据删除成功";
            }
            catch (Exception e)
            {
                Logger.Instance.Error(this, "删除数据出错", e);
                return "0:数据删除失败";
            }
        }

        /// <summary>
        /// 根据船期ID找到该记录。
        /// </summary>
        /// <param name="scd_id"></param>
        /// <returns></returns>
        public DataTable SelectTableBySCD_ID(string scd_id)
        {
            try
            {
                return dal.SelectTableBySCD_ID(scd_id);
            }
            catch (Exception e)
            {
                Logger.Instance.Error(this, "查找数据出错", e);
                throw;
            }
        }

        /// <summary>
        /// 根据sln_id找到服务航线记录。
        /// </summary>
        /// <param name="scd_id"></param>
        /// <returns></returns>
        public DataTable SelectService_Line(string sln_id)
        {
            try
            {
                return dal.SelectService_Line(sln_id);
            }
            catch (Exception e)
            {
                Logger.Instance.Error(this, "查找数据出错", e);
                throw;
            }
        }

    }//end class
}
